
package com.wa.nashorn;
import java.util.concurrent.LinkedTransferQueue;
import jdk.nashorn.api.scripting.ScriptObjectMirror;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RawTransferNashornScript extends AbstractRawTransferNashornScript<Object> {
    private static final Logger LOGGER = LoggerFactory.getLogger(RawTransferNashornScript.class);
    private String scriptName = "";
    private Object[] param;
    private String functionName;
    private String script;
    private StringBuilder loggerBuilder;

    public RawTransferNashornScript(LinkedTransferQueue<Object> queue, String scriptName, Object[] param, String functionName, String script) {
        super(queue);
        this.scriptName = scriptName;
        this.param = param;
        this.functionName = functionName;
        this.script = script;
    }

    public String getScript() {
        return this.script;
    }

    String getScriptName() {
        return this.scriptName;
    }

    Object processInternal(ScriptObjectMirror objectMirror) {
        return objectMirror.callMember(this.functionName, this.param);
    }

    public StringBuilder getLoggerBuilder() {
        return this.loggerBuilder;
    }

    public void setLoggerBuilder(StringBuilder loggerBuilder) {
        this.loggerBuilder = loggerBuilder;
    }

    public StringBuilder getLoggerOutputBuilder() {
        return this.loggerBuilder;
    }

//    public void processTemplateIntoString(Map<String, String> model) {
//        try {
//            Template freeMarkerTemplate = new Template("", this.getScript(), new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS));
//            this.script = FreeMarkerTemplateUtils.processTemplateIntoString(freeMarkerTemplate, model);
//        } catch (Exception var3) {
//            LOGGER.error("Invalid template, script= {} map = {}", new Object[]{this.getScript(), model, var3});
//        }
//
//    }
}
